package com.geek.novel.entity

import com.geek.novel.utils.SnowIdUtil
import io.realm.RealmObject
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
import io.realm.annotations.RealmClass


/**
 * 全本缓存记录
 * @Author Hydra
 * @Date 2022/7/25 17:09
 */
@RealmClass
open class BookDownload : RealmObject() {

	/**
     * id
     */
	@PrimaryKey
    open var id: Long = 0

	/**书籍id*/
	open var bookId: String = ""

	/**书籍爬虫源的信息*/
	open var bookCrawlerId: Long = 0

	/**当前爬取的下标*/
	open var crawlerIndex: Int = 0

	/**
	 * 状态
	 * 0: 未开始
	 * 1: 下载中
	 * 2: 完成
	 * -1: 暂停
	 * @see com.geek.novel.common.BookDownloadEnum
	 */
	open var status: Int = 0


	/**是否出错*/
	@Ignore
	open var error: Boolean = false
	/**loading信息*/
	@Ignore
	open var loadingMessage: String = ""


	fun initEntity(bookId: String){
		this.id = SnowIdUtil.getInstance().nextId()
		this.bookId = bookId
		this.status = 0
	}

}